<?php
require_once "../include/connectionHandlers/sessionHandling.php";

class login_controller
{
	private $login = "demo";
	private $password; 
	
	private $sesHandler;
	
	public function __construct()
	{
		$this->password = sha1("demo");
		$this->sesHandler = sessionHandling::instantiate();
		if(isset($_POST["authenticationButton"]))
		{
			if(isset($_POST["login"]) && isset($_POST["password"])){ $this->authenticate();}
			else{$this->displayLoginOrPasswordMissing();}
		}
	}
	
	private function authenticate()
	{
		$currentLogin = $_POST["login"];
		$currentPassword = sha1($_POST["password"]);
					
		if($currentLogin == $this->login && $this->password == $currentPassword)
		{
			$this->sesHandler->authenticate($currentLogin);
			header("location:administration.php");
		}	
	}
	
	private function displayLoginOrPasswordMissing(){}
}
?>